package view;

import brain.SortManager;
import com.hexapixel.widgets.generic.ImageCache;
import com.hexapixel.widgets.generic.Utils;
import com.hexapixel.widgets.ribbon.RibbonButton;
import com.hexapixel.widgets.ribbon.RibbonButtonGroup;
import com.hexapixel.widgets.ribbon.RibbonCheckbox;
import com.hexapixel.widgets.ribbon.RibbonGroup;
import com.hexapixel.widgets.ribbon.RibbonGroupSeparator;
import com.hexapixel.widgets.ribbon.RibbonTab;
import com.hexapixel.widgets.ribbon.RibbonTabFolder;
import control.RemoveControl;
import control.SortControl;
import control.SourceControl;
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.Panel;
import java.util.ArrayList;
import java.util.Iterator;
import managment.InType;
import managment.Prop;
import model.Sorters;
import model.Statistics;
import org.eclipse.nebula.widgets.pshelf.PShelf;
import org.eclipse.nebula.widgets.pshelf.PShelfItem;
import org.eclipse.nebula.widgets.pshelf.RedmondShelfRenderer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import simulation.Painter;
import simulation.Visualizer;
import viewControl.StartListener;

/**
 * @author  Owner
 */
@SuppressWarnings("unused")
public class View {
	
	final Shell shell;
	
    private Painter painter;
    	
	private Text path;

	private Font font;

	private List sortList;

	private Color color;

	private Label selectionT1;

	private Label selectionT2;

	private Label selectionT3;

	private Label insertionT1;

	private Label insertionT2;

	private Label insertionT3;

	private Label shellT1;

	private Label shellT2;

	private Label shellT3;

	private Label mergeT3;

	private Label mergeT2;

	private Label mergeT1;

	private Label quickT1;

	private Label quickT2;

	private Label quickT3;

	private Label heapT3;

	private Label heapT1;

	private Label heapT2;

	private Label bubbleT3;

	private Label bubbleT2;

	private Label bubbleT1;

	private RibbonButton remove;

	private SortControl sortControl;
	
	private static View tester;
	
	private ImageData loadData = new ImageData(getClass().getResourceAsStream("dis_selection_recycle_24.png"));

	private Text sizeText;

	private RibbonCheckbox selectionSort;

	private RibbonCheckbox bubbleSort;

	private RibbonCheckbox shellSort;

	private RibbonCheckbox insertionSort;

	private RibbonCheckbox heapSort;

	private RibbonCheckbox quickSort;

	private RibbonCheckbox mergeSort;

	private Canvas visualView;

	private int canvasWidth;
	
	private int cnvasHeight;
	
	private Display display;

	private Label simSortType;

	public static View getInstance() {
		if (tester == null) 
			tester = new View();
		return tester;
	}

	private View() {
		display = new Display();
		shell = new Shell(display);
	}

	public void initView() {

		shell.setText("Welcome to our Sorting Simulator");
		ImageData shellData = new ImageData(getClass().getResourceAsStream(
				"shell.png"));
		shell.setImage(new Image(display, shellData));
		shell.setMaximized(true);
		shell.setLayout(new FillLayout());
		color = display.getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND);
		font = new Font(display, "Times New Roman", 12, SWT.NORMAL);

		Composite inner = new Composite(shell, SWT.None);
		inner.setLayout(new GridLayout(1, true));

		GridData data = new GridData(GridData.FILL_HORIZONTAL);
		data.heightHint = 119;
		// Tab folder
		final RibbonTabFolder tabFolder = new RibbonTabFolder(inner, SWT.NONE);
		tabFolder.setLayoutData(data);
		
		
		// Tabs
		// ////////////////////////Tab0////////////////////////////////
		RibbonTab inputTab = new RibbonTab(tabFolder, "Input Source");

		// external input group:
		RibbonGroup external = new RibbonGroup(inputTab, "External Input");
		path = new Text(external, SWT.BORDER);
		path.setBackground(Display.getCurrent().getSystemColor(
				SWT.COLOR_TITLE_INACTIVE_FOREGROUND));
		path.setBounds(12, 29, 172, 23);
		new RibbonGroupSeparator(external);
		RibbonButtonGroup BG = new RibbonButtonGroup(external);
		RibbonButton browse = new RibbonButton(BG, ImageCache
				.getImage("folder_16.gif"), "  Browse system directory      ",
				RibbonButton.STYLE_ARROW_DOWN_SPLIT);
		new RibbonGroupSeparator(external);
		
		final RibbonButton load = new RibbonButton(external, 
			new Image(null, loadData),
				"Load from the \nspecified directory ",
				RibbonButton.STYLE_NO_DEPRESS | 
				RibbonButton.STYLE_ARROW_DOWN
						| RibbonButton.STYLE_TOGGLE
						| RibbonButton.STYLE_TWO_LINE_TEXT);
		load.setEnabled(false);
		load.addSelectionListener(new SourceControl(InType.file , null));
		browse.addSelectionListener(new SelectionListener() {
			public void widgetDefaultSelected(SelectionEvent e) {
			}

			public void widgetSelected(SelectionEvent e) {
				DirectoryDialog dlg = new DirectoryDialog(shell);
				dlg.setFilterPath(path.getText());
				dlg.setText("Directory Dialog");
				dlg.setMessage("Select a directory to Load");

				String dir = dlg.open();
				if (dir != null ) {
					path.setText(dir);
					load.setEnabled(true);
					load.setImage(ImageCache.
						getImage("selection_recycle_24.png"));
				}
			}

		});
		path.addModifyListener(new ModifyListener() {
			public void modifyText(ModifyEvent e) {
				if (path.getText().equals("") || path.getText() == null) {
					load.setEnabled(false);
					load.setImage(new Image(null, loadData));
				} else {
					load.setEnabled(true);
					load.setImage(ImageCache.
						getImage("selection_recycle_24.png"));
				}
			}
		});
		new RibbonGroupSeparator(external);

		// list group:
		RibbonGroup listGroup = new RibbonGroup(inputTab,
				"List of arrays to sort");

		// the list:
		listGroup.setLayout(null);
		ImageData bData = new ImageData(getClass().getResourceAsStream(
				"bridge2.png"));
		new RibbonGroupSeparator(listGroup);
		RibbonButtonGroup BG2 = new RibbonButtonGroup(listGroup);

		new RibbonButton(BG2, new Image(null, bData), null,
				RibbonButton.STYLE_NONE);
		new RibbonButton(BG2, new Image(null, bData), null,
				RibbonButton.STYLE_NONE);

		this.sortList = new List(listGroup, SWT.V_SCROLL | SWT.BORDER |SWT.CENTER |SWT.SINGLE);
		this.sortList.setBounds(12, 2, 186, 44);
		this.sortList.setBackground(display.getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND));
		this.sortList.setCursor(new Cursor(display,SWT.CURSOR_HAND));

		
		remove = new RibbonButton(BG2, ImageCache.getImage("disabled_small.gif"), "Remove from list",RibbonButton.STYLE_ARROW_DOWN_SPLIT);
		remove.setEnabled(false);
		remove.setDisabledImage(ImageCache.getImage("disabled_small.gif"));
		
		new RibbonGroupSeparator(listGroup);
		remove.addSelectionListener(new RemoveControl());
		
		this.sortList.addSelectionListener(new SelectionListener() {
			public void widgetDefaultSelected(SelectionEvent arg0) {
			}

			public void widgetSelected(SelectionEvent arg0) {
				if (sortList.getSelectionIndex() != -1) {
					remove.setEnabled(true);
					remove.setImage(ImageCache.getImage(
						"enabled_small.gif"));
				} else {
					remove.setEnabled(false);
					remove.setImage(ImageCache.getImage(
						"disabled_small.gif"));
				}
			}
		});

		// Internal Input Group
		RibbonGroup inIpGp = new RibbonGroup(inputTab, "Internal Input");
		inIpGp.setLayout(null);
		// text box:
		ImageData tempData = new ImageData(getClass().getResourceAsStream(
				"bridge.jpeg"));
		new RibbonButton(inIpGp, new Image(null, tempData), null,
				RibbonButton.STYLE_NONE);
		Group sizeGp = new Group(inIpGp, SWT.SHADOW_IN);
		sizeGp.setLocation(4, 2);
		sizeGp.setSize(86, 66);
		sizeGp.setBackground(display.getSystemColor(
				SWT.COLOR_TITLE_INACTIVE_FOREGROUND));
		sizeGp.setText("Array size");
		sizeGp.setLayout(null);
		new Label(sizeGp, SWT.NONE);
		sizeText = new Text(sizeGp, SWT.BORDER | SWT.WRAP);
		sizeText.setBackground(display
				.getSystemColor(SWT.COLOR_TITLE_INACTIVE_FOREGROUND));
		sizeText.setBounds(20, 30, 40, 20);

		// separator:
		new RibbonGroupSeparator(inIpGp);
		
		final RibbonButton addAutoSorted = new RibbonButton(inIpGp, 
			new Image(null, getClass().getResourceAsStream("incgraph.gif")),
				"Generate \nSorted Array",
				RibbonButton.STYLE_NO_DEPRESS|
				RibbonButton.STYLE_TWO_LINE_TEXT);
		addAutoSorted.setDisabledImage(new Image(display, getClass().getResourceAsStream("dis_incgraph.jpg")));
		
		
		// add button:
		final RibbonButton addAutoRandom = new RibbonButton(inIpGp, 
			new Image(null, getClass().getResourceAsStream("random.png")),
				"Generate \nRandom Array",
				RibbonButton.STYLE_NO_DEPRESS|
				RibbonButton.STYLE_TWO_LINE_TEXT);
		addAutoRandom.setDisabledImage(new Image(null, getClass().getResourceAsStream("dis_rando.png")));
		
		final RibbonButton addAutoInverse = new RibbonButton(inIpGp, 
			new Image(display, getClass().getResourceAsStream("decgraph.gif")),
				"Generate\ninversly-Sorted Array",
				RibbonButton.STYLE_NO_DEPRESS |
				RibbonButton.STYLE_TWO_LINE_TEXT );
		addAutoInverse.setDisabledImage(new Image(display, getClass().getResourceAsStream("dis_decgraph.jpg")));
		
		
		addAutoInverse.addSelectionListener(new SourceControl(InType.auto ,Prop.invSorted));
		addAutoRandom.addSelectionListener(new SourceControl(InType.auto ,Prop.random));
		addAutoSorted.addSelectionListener(new SourceControl(InType.auto ,Prop.sorted));
		
		// initially addAuto buttons is disabled:
		addAutoInverse.setEnabled(false);
		addAutoRandom.setEnabled(false);
		addAutoSorted.setEnabled(false);
		
		sizeText.addModifyListener(new ModifyListener() {
			public void modifyText(ModifyEvent arg0) {
				try {
					int foo = Integer.parseInt(sizeText.getText());
					if(foo < 0){
						throw new NumberFormatException();
					}
					addAutoInverse.setEnabled(true);
					addAutoRandom.setEnabled(true);
					addAutoSorted.setEnabled(true);
				} catch (NumberFormatException e) {
					addAutoInverse.setEnabled(false);
					addAutoRandom.setEnabled(false);
					addAutoSorted.setEnabled(false);
				}
			}
		});
		// ////////////////////////end Tab0/////////////////////////////////

		// ///////////////////////start Tab1////////////////////////////////

		RibbonTab simTab = new RibbonTab(tabFolder, "Simulation Options");

		RibbonGroup simWays1 = new RibbonGroup(simTab, "Algorithms to simulate");
		RibbonButtonGroup simWaysBut = new RibbonButtonGroup(simWays1);

		
		selectionSort = new RibbonCheckbox(simWaysBut, "Selection sort",SWT.NONE);
		selectionSort.setSelected(true);

		bubbleSort = new RibbonCheckbox(simWaysBut, "Bubble sort", SWT.NONE);
		shellSort = new RibbonCheckbox(simWaysBut, "Shell sort", SWT.NONE);
		insertionSort = new RibbonCheckbox(simWaysBut, "Insertion sort",SWT.NONE);
		heapSort = new RibbonCheckbox(simWaysBut, "Heap sort", SWT.NONE);
		quickSort = new RibbonCheckbox(simWaysBut, "Quick sort", SWT.NONE);
		mergeSort = new RibbonCheckbox(simWaysBut, "Merge sort",SWT.NONE);
		
		RibbonCheckbox setStat = new RibbonCheckbox(simWaysBut,"Show statistics after finish", SWT.NONE);
		setStat.setSelected(true);
		RibbonButton setDef = new RibbonButton(simWaysBut, null,"Restore default options", RibbonButton.STYLE_ARROW_DOWN_SPLIT);
		RibbonGroup conaole = new RibbonGroup(simTab, "Console vis.");
		RibbonButton rb3 = new RibbonButton(conaole, 
			new Image(null, getClass().getResourceAsStream("console.png")),
				null, RibbonButton.STYLE_ARROW_DOWN
						| RibbonButton.STYLE_TOGGLE
						| RibbonButton.STYLE_TWO_LINE_TEXT);

		// ////////////////////////end Tab1/////////////////////////////////

		// initialize inner composite
		initInnerComposite(inner);

		Utils.centerDialogOnScreen(shell.getShell());
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();

	}

	private void initInnerComposite(Composite inner) {
		inner.setBackground(color);
		Composite composite = new Composite(inner, SWT.BORDER | SWT.CENTER);
		composite.setBackground(color);
		GridData gData = new GridData(GridData.FILL_BOTH);
		composite.setLayoutData(gData);
		composite.setLayout(new GridLayout(2, false));

		Composite leftComposite =new Composite(composite,SWT.NONE);
		leftComposite.setLayout(new GridLayout());
		gData = new GridData(GridData.FILL_VERTICAL);
		gData.widthHint = 230;
		leftComposite.setBackground(color);
		leftComposite.setLayoutData(gData);
		
		PShelf shelf = new PShelf(leftComposite, SWT.BORDER);
		gData = new GridData(GridData.FILL_VERTICAL|GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
		shelf.setLayoutData(gData);
		
		FormLayout layout = new FormLayout();
		FormData data = new FormData();
		shelf.setRenderer(new RedmondShelfRenderer());

		PShelfItem bubble = new PShelfItem(shelf, SWT.NONE);
		bubble.setText("Bubble Sort");
		Composite bubbleComposite = bubble.getBody();
		bubbleComposite.setBackground(color);
		layout = new FormLayout();
		bubbleComposite.setLayout(layout);
		// ---------------------------------------------
		Label l0 = new Label(bubbleComposite, SWT.NORMAL);
		l0.setImage(new Image(null,getClass().getResourceAsStream("clock.png")));
		data = new FormData();
		data.top = new FormAttachment(0, 10);
		data.left = new FormAttachment(0, 5);
		data.right = new FormAttachment(0, 25);
		l0.setLayoutData(data);
		l0.setBackground(color);
		/******************************************/
		/**********************************************/
		Label l1 = new Label(bubbleComposite, SWT.NORMAL);
		l1.setFont(font);
		l1.setBackground(color);
		l1.setText("Run Time (ns)");
		data = new FormData();
		data.top = new FormAttachment(0, 10);
		data.left = new FormAttachment(0, 35);
		data.right = new FormAttachment(0, 120);
		l1.setLayoutData(data);

		
		bubbleT1 = new Label(bubbleComposite, SWT.BORDER | SWT.CENTER
				| SWT.CENTER);
		bubbleT1.setBackground(color);
		bubbleT1.setFont(font);
		data = new FormData();
		data.top = new FormAttachment(0, 3);
                data.left = new FormAttachment(0, 120);
		data.right = new FormAttachment(97, 0);
		data.bottom = new FormAttachment(0, 30);
		bubbleT1.setLayoutData(data);

		// ---------------------------------------------
		Label l01 = new Label(bubbleComposite, SWT.NORMAL);
		l01.setBackground(color);
		l01.setImage(new Image(null,getClass().getResourceAsStream("check.png")));
		data = new FormData();
		data.top = new FormAttachment(0, 37);
		data.left = new FormAttachment(0, 5);
		data.right = new FormAttachment(0, 25);
		l01.setLayoutData(data);
		/******************************************/
		/**********************************************/
		
		Label l2 = new Label(bubbleComposite, SWT.NORMAL);
		l2.setFont(font);
		l2.setBackground(color);
		l2.setText("checks");
		data = new FormData();
		data.top = new FormAttachment(0, 37);
		data.left = new FormAttachment(0, 35);
		data.right = new FormAttachment(0, 110);
		l2.setLayoutData(data);

		bubbleT2 = new Label(bubbleComposite, SWT.BORDER | SWT.CENTER
				| SWT.CENTER);
		bubbleT2.setBackground(color);
		bubbleT2.setFont(font);
		data = new FormData();
		data.top = new FormAttachment(0, 30);
                data.left = new FormAttachment(0, 120);
		data.right = new FormAttachment(97, 0);
		data.bottom = new FormAttachment(0, 57);
		bubbleT2.setLayoutData(data);
		// ---------------------------------------------
		Label l20 = new Label(bubbleComposite, SWT.NORMAL);
		l20.setImage(new Image(null,getClass().getResourceAsStream("swap.png")));
		data = new FormData();
		data.top = new FormAttachment(0, 64);
		data.left = new FormAttachment(0, 5);
		data.right = new FormAttachment(0, 25);
		l20.setLayoutData(data);
		l20.setBackground(color);
		/**********************************************/
		
		Label l3 = new Label(bubbleComposite, SWT.NORMAL);
		l3.setFont(font);
		l3.setBackground(color);
		l3.setText("Swaps");
		data = new FormData();
		data.top = new FormAttachment(0, 64);
		data.left = new FormAttachment(0, 35);
		data.right = new FormAttachment(0, 100);
		l3.setLayoutData(data);

		bubbleT3 = new Label(bubbleComposite, SWT.BORDER | SWT.CENTER
				| SWT.CENTER);
		bubbleT3.setBackground(color);
		bubbleT3.setFont(font);
		data = new FormData();
		data.top = new FormAttachment(0, 57);
		data.left = new FormAttachment(0, 120);
		data.right = new FormAttachment(97, 0);
		data.bottom = new FormAttachment(0, 84);
		bubbleT3.setLayoutData(data);
		// ---------------------------------------------
		/** ***************************************************************** */
		PShelfItem selection = new PShelfItem(shelf, SWT.NONE);
		selection.setText("Selection Sort");
		Composite selectionComposite = selection.getBody();
		selectionComposite.setBackground(color);
		layout = new FormLayout();
		selectionComposite.setLayout(layout);
		// ---------------------------------------------
		Label l200 = new Label(selectionComposite, SWT.NORMAL);
		l200.setImage(new Image(null,getClass().getResourceAsStream("clock.png")));
		data = new FormData();
		data.top = new FormAttachment(0, 10);
		data.left = new FormAttachment(0, 5);
		data.right = new FormAttachment(0, 25);
		l200.setLayoutData(data);
		l200.setBackground(color);
		
		Label l11 = new Label(selectionComposite, SWT.NORMAL);
		l11.setFont(font);
		l11.setBackground(color);
		l11.setText("Run Time (ns)");
		data = new FormData();
		data.top = new FormAttachment(0, 10);
		data.left = new FormAttachment(0, 35);
		data.right = new FormAttachment(0, 120);
		l11.setLayoutData(data);
		l11.setBackground(color);

		selectionT1 = new Label(selectionComposite, SWT.BORDER | SWT.CENTER);
		selectionT1.setBackground(color);
		selectionT1.setFont(font);
		data = new FormData();
		data.top = new FormAttachment(0, 3);
		data.left = new FormAttachment(0, 120);
		data.right = new FormAttachment(97, 0);
		data.bottom = new FormAttachment(0, 30);
		selectionT1.setLayoutData(data);
		selectionT1.setText("4893638290");
		// ---------------------------------------------
		Label l201 = new Label(selectionComposite, SWT.NORMAL);
		l201.setImage(new Image(null,getClass().getResourceAsStream("check.png")));
		data = new FormData();
		data.top = new FormAttachment(0, 37);
		data.left = new FormAttachment(0, 5);
		data.right = new FormAttachment(0, 25);
		l201.setLayoutData(data);
		l201.setBackground(color);
		
		Label l12 = new Label(selectionComposite, SWT.NORMAL);
		l12.setFont(font);
		l12.setBackground(color);
		l12.setText("checks");
		data = new FormData();
		data.top = new FormAttachment(0, 37);
		data.left = new FormAttachment(0, 35);
		data.right = new FormAttachment(0, 100);
		l12.setLayoutData(data);

		selectionT2 = new Label(selectionComposite, SWT.BORDER | SWT.CENTER
				| SWT.CENTER);
		selectionT2.setBackground(color);
		selectionT2.setFont(font);
		data = new FormData();
		data.top = new FormAttachment(0, 30);
		data.left = new FormAttachment(0, 120);
		data.right = new FormAttachment(97, 0);
		data.bottom = new FormAttachment(0, 57);
		selectionT2.setLayoutData(data);
		// ---------------------------------------------
		Label l202 = new Label(selectionComposite, SWT.NORMAL);
		l202.setImage(new Image(null,getClass().getResourceAsStream("swap.png")));
		data = new FormData();
		data.top = new FormAttachment(0, 64);
		data.left = new FormAttachment(0, 5);
		data.right = new FormAttachment(0, 25);
		l202.setLayoutData(data);
		l202.setBackground(color);
		
		Label l13 = new Label(selectionComposite, SWT.NORMAL);
		l13.setFont(font);
		l13.setBackground(color);
		l13.setText("Swaps");
		data = new FormData();
		data.top = new FormAttachment(0, 64);
		data.left = new FormAttachment(0, 35);
		data.right = new FormAttachment(0, 100);
		l13.setLayoutData(data);

		selectionT3 = new Label(selectionComposite, SWT.BORDER | SWT.CENTER);
		selectionT3.setBackground(color);
		selectionT3.setFont(font);
		data = new FormData();
		data.top = new FormAttachment(0, 57);
		data.left = new FormAttachment(0, 120);
		data.right = new FormAttachment(97, 0);
		data.bottom = new FormAttachment(0, 84);
		selectionT3.setLayoutData(data);
		// ---------------------------------------------
		/** ***************************************************************** */
		PShelfItem insertion = new PShelfItem(shelf, SWT.NONE);
		insertion.setText("Insertion Sort");
		Composite insertionComposite = insertion.getBody();
		insertionComposite.setBackground(color);
		layout = new FormLayout();
		insertionComposite.setLayout(layout);
		// ---------------------------------------------
		Label l210 = new Label(insertionComposite, SWT.NORMAL);
		l210.setImage(new Image(null,getClass().getResourceAsStream("clock.png")));
		data = new FormData();
		data.top = new FormAttachment(0, 10);
		data.left = new FormAttachment(0, 5);
		data.right = new FormAttachment(0, 25);
		l210.setLayoutData(data);
		l210.setBackground(color);
		
		Label l21 = new Label(insertionComposite, SWT.NORMAL);
		l21.setFont(font);
		l21.setBackground(color);
		l21.setText("Run Time (ns)");
		data = new FormData();
		data.top = new FormAttachment(0, 10);
		data.left = new FormAttachment(0, 35);
		data.right = new FormAttachment(0, 120);
		l21.setLayoutData(data);
		l21.setBackground(color);

		insertionT1 = new Label(insertionComposite, SWT.BORDER | SWT.CENTER
				| SWT.CENTER);
		insertionT1.setBackground(color);
		insertionT1.setFont(font);
		data = new FormData();
		data.top = new FormAttachment(0, 3);
		data.left = new FormAttachment(0, 120);
		data.right = new FormAttachment(97, 0);
		data.bottom = new FormAttachment(0, 30);
		insertionT1.setLayoutData(data);

		// ---------------------------------------------
		Label l211 = new Label(insertionComposite, SWT.NORMAL);
		l211.setImage(new Image(null,getClass().getResourceAsStream("check.png")));
		data = new FormData();
		data.top = new FormAttachment(0, 37);
		data.left = new FormAttachment(0, 5);
		data.right = new FormAttachment(0, 25);
		l211.setLayoutData(data);
		l211.setBackground(color);
		
		
		Label l22 = new Label(insertionComposite, SWT.NORMAL);
		l22.setFont(font);
		l22.setBackground(color);
		l22.setText("checks");
		data = new FormData();
		data.top = new FormAttachment(0, 37);
		data.left = new FormAttachment(0, 35);
		data.right = new FormAttachment(0, 100);
		l22.setLayoutData(data);

		insertionT2 = new Label(insertionComposite, SWT.BORDER | SWT.CENTER);
		insertionT2.setBackground(color);
		insertionT2.setFont(font);
		data = new FormData();
		data.top = new FormAttachment(0, 30);
		data.left = new FormAttachment(0, 120);
		data.right = new FormAttachment(97, 0);
		data.bottom = new FormAttachment(0, 57);
		insertionT2.setLayoutData(data);
		// ---------------------------------------------
		Label l212 = new Label(insertionComposite, SWT.NORMAL);
		l212.setImage(new Image(null,getClass().getResourceAsStream("swap.png")));
		data = new FormData();
		data.top = new FormAttachment(0, 64);
		data.left = new FormAttachment(0, 5);
		data.right = new FormAttachment(0, 25);
		l212.setLayoutData(data);
		l212.setBackground(color);
		
		Label l23 = new Label(insertionComposite, SWT.NORMAL);
		l23.setFont(font);
		l23.setBackground(color);
		l23.setText("Swaps");
		data = new FormData();
		data.top = new FormAttachment(0, 64);
		data.left = new FormAttachment(0, 35);
		data.right = new FormAttachment(0, 100);
		l23.setLayoutData(data);

		insertionT3 = new Label(insertionComposite, SWT.BORDER | SWT.CENTER);
		insertionT3.setBackground(color);
		insertionT3.setFont(font);
		data = new FormData();
		data.top = new FormAttachment(0, 57);
		data.left = new FormAttachment(0, 120);
		data.right = new FormAttachment(97, 0);
		data.bottom = new FormAttachment(0, 84);
		insertionT3.setLayoutData(data);
		// ---------------------------------------------
		/** ***************************************************************** */
		PShelfItem shell = new PShelfItem(shelf, SWT.NONE);
		shell.setText("Shell Sort");
		Composite shellComposite = shell.getBody();
		shellComposite.setBackground(color);
		layout = new FormLayout();
		shellComposite.setLayout(layout);
		// ---------------------------------------------
		Label l220 = new Label(shellComposite, SWT.NORMAL);
		l220.setImage(new Image(null,getClass().getResourceAsStream("clock.png")));
		data = new FormData();
		data.top = new FormAttachment(0, 10);
		data.left = new FormAttachment(0, 5);
		data.right = new FormAttachment(0, 25);
		l220.setLayoutData(data);
		l220.setBackground(color);
		
		
		Label l31 = new Label(shellComposite, SWT.NORMAL);
		l31.setFont(font);
		l31.setBackground(color);
		l31.setText("Run Time (ns)");
		data = new FormData();
		data.top = new FormAttachment(0, 10);
		data.left = new FormAttachment(0, 35);
		data.right = new FormAttachment(0, 120);
		l31.setLayoutData(data);
		l31.setBackground(color);

		shellT1 = new Label(shellComposite, SWT.BORDER | SWT.CENTER
				| SWT.CENTER);
		shellT1.setBackground(color);
		shellT1.setFont(font);
		data = new FormData();
		data.top = new FormAttachment(0, 3);
		data.left = new FormAttachment(0, 120);
		data.right = new FormAttachment(97, 0);
		data.bottom = new FormAttachment(0, 30);
		shellT1.setLayoutData(data);

		// ---------------------------------------------
		Label l221 = new Label(shellComposite, SWT.NORMAL);
		l221.setImage(new Image(null,getClass().getResourceAsStream("check.png")));
		data = new FormData();
		data.top = new FormAttachment(0, 37);
		data.left = new FormAttachment(0, 5);
		data.right = new FormAttachment(0, 25);
		l221.setLayoutData(data);
		l221.setBackground(color);
		
		
		Label l32 = new Label(shellComposite, SWT.NORMAL);
		l22.setFont(font);
		l32.setBackground(color);
		l32.setText("checks");
		data = new FormData();
		data.top = new FormAttachment(0, 37);
		data.left = new FormAttachment(0, 35);
		data.right = new FormAttachment(0, 100);
		l32.setLayoutData(data);

		shellT2 = new Label(shellComposite, SWT.BORDER | SWT.CENTER
				| SWT.CENTER);
		shellT2.setBackground(color);
		shellT2.setFont(font);
		data = new FormData();
		data.top = new FormAttachment(0, 30);
		data.left = new FormAttachment(0, 120);
		data.right = new FormAttachment(97, 0);
		data.bottom = new FormAttachment(0, 57);
		shellT2.setLayoutData(data);
		// ---------------------------------------------
		Label l222 = new Label(shellComposite, SWT.NORMAL);
		l222.setImage(new Image(null,getClass().getResourceAsStream("swap.png")));
		data = new FormData();
		data.top = new FormAttachment(0, 64);
		data.left = new FormAttachment(0, 5);
		data.right = new FormAttachment(0, 25);
		l222.setLayoutData(data);
		l222.setBackground(color);
		
		
		Label l33 = new Label(shellComposite, SWT.NORMAL);
		l33.setFont(font);
		l33.setBackground(color);
		l33.setText("Swaps");
		data = new FormData();
		data.top = new FormAttachment(0, 64);
		data.left = new FormAttachment(0, 35);
		data.right = new FormAttachment(0, 100);
		l33.setLayoutData(data);

		shellT3 = new Label(shellComposite, SWT.BORDER | SWT.CENTER);
		shellT3.setBackground(color);
		shellT3.setFont(font);
		data = new FormData();
		data.top = new FormAttachment(0, 57);
		data.left = new FormAttachment(0, 120);
		data.right = new FormAttachment(97, 0);
		data.bottom = new FormAttachment(0, 84);
		shellT3.setLayoutData(data);
		// ---------------------------------------------
		/** ***************************************************************** */
		PShelfItem merge = new PShelfItem(shelf, SWT.NONE);
		merge.setText("Merge Sort");
		Composite mergeComposite = merge.getBody();
		mergeComposite.setBackground(color);
		layout = new FormLayout();
		mergeComposite.setLayout(layout);
		// ---------------------------------------------
		Label l300 = new Label(mergeComposite, SWT.NORMAL);
		l300.setImage(new Image(null,getClass().getResourceAsStream("clock.png")));
		data = new FormData();
		data.top = new FormAttachment(0, 10);
		data.left = new FormAttachment(0, 5);
		data.right = new FormAttachment(0, 25);
		l300.setLayoutData(data);
		l300.setBackground(color);
		
		
		Label l41 = new Label(mergeComposite, SWT.NORMAL);
		l41.setFont(font);
		l41.setBackground(color);
		l41.setText("Run Time (ns)");
		data = new FormData();
		data.top = new FormAttachment(0, 10);
		data.left = new FormAttachment(0, 35);
		data.right = new FormAttachment(0, 120);
		l41.setLayoutData(data);
		l41.setBackground(color);

		mergeT1 = new Label(mergeComposite, SWT.BORDER | SWT.CENTER);
		mergeT1.setBackground(color);
		mergeT1.setFont(font);
		data = new FormData();
		data.top = new FormAttachment(0, 3);
		data.left = new FormAttachment(0, 120);
		data.right = new FormAttachment(97, 0);
		data.bottom = new FormAttachment(0, 30);
		mergeT1.setLayoutData(data);

		// ---------------------------------------------
		Label l301 = new Label(mergeComposite, SWT.NORMAL);
		l301.setImage(new Image(null,getClass().getResourceAsStream("check.png")));
		data = new FormData();
		data.top = new FormAttachment(0, 37);
		data.left = new FormAttachment(0, 5);
		data.right = new FormAttachment(0, 25);
		l301.setLayoutData(data);
		l301.setBackground(color);
		
		
		Label l42 = new Label(mergeComposite, SWT.NORMAL);
		l42.setFont(font);
		l42.setBackground(color);
		l42.setText("checks");
		data = new FormData();
		data.top = new FormAttachment(0, 37);
		data.left = new FormAttachment(0, 35);
		data.right = new FormAttachment(0, 100);
		l42.setLayoutData(data);

		mergeT2 = new Label(mergeComposite, SWT.BORDER | SWT.CENTER);
		mergeT2.setBackground(color);
		mergeT2.setFont(font);
		data = new FormData();
		data.top = new FormAttachment(0, 30);
		data.left = new FormAttachment(0, 120);
		data.right = new FormAttachment(97, 0);
		data.bottom = new FormAttachment(0, 57);
		mergeT2.setLayoutData(data);
		// ---------------------------------------------
		Label l302 = new Label(mergeComposite, SWT.NORMAL);
		l302.setImage(new Image(null,getClass().getResourceAsStream("swap.png")));
		data = new FormData();
		data.top = new FormAttachment(0, 64);
		data.left = new FormAttachment(0, 5);
		data.right = new FormAttachment(0, 25);
		l302.setLayoutData(data);
		l302.setBackground(color);
		
		
		Label l43 = new Label(mergeComposite, SWT.NORMAL);
		l43.setFont(font);
		l43.setBackground(color);
		l43.setText("Swaps");
		data = new FormData();
		data.top = new FormAttachment(0, 64);
		data.left = new FormAttachment(0, 35);
		data.right = new FormAttachment(0, 100);
		l43.setLayoutData(data);

		mergeT3 = new Label(mergeComposite, SWT.BORDER | SWT.CENTER);
		mergeT3.setBackground(color);
		mergeT3.setFont(font);
		data = new FormData();
		data.top = new FormAttachment(0, 57);
		data.left = new FormAttachment(0, 120);
		data.right = new FormAttachment(97, 0);
		data.bottom = new FormAttachment(0, 84);
		mergeT3.setLayoutData(data);
		// ---------------------------------------------
		/** ***************************************************************** */
		PShelfItem quick = new PShelfItem(shelf, SWT.NONE);
		quick.setText("Quick Sort");
		Composite quickComposite = quick.getBody();
		quickComposite.setBackground(color);
		layout = new FormLayout();
		quickComposite.setLayout(layout);
		// ---------------------------------------------
		Label l310 = new Label(quickComposite, SWT.NORMAL);
		l310.setImage(new Image(null,getClass().getResourceAsStream("clock.png")));
		data = new FormData();
		data.top = new FormAttachment(0, 10);
		data.left = new FormAttachment(0, 5);
		data.right = new FormAttachment(0, 25);
		l310.setLayoutData(data);
		l310.setBackground(color);
		
		Label l51 = new Label(quickComposite, SWT.NORMAL);
		l51.setFont(font);
		l51.setBackground(color);
		l51.setText("Run Time (ns)");
		data = new FormData();
		data.top = new FormAttachment(0, 10);
		data.left = new FormAttachment(0, 35);
		data.right = new FormAttachment(0, 120);
		l51.setLayoutData(data);
		l51.setBackground(color);

		quickT1 = new Label(quickComposite, SWT.BORDER | SWT.CENTER);
		quickT1.setBackground(color);
		quickT1.setFont(font);
		data = new FormData();
		data.top = new FormAttachment(0, 3);
		data.left = new FormAttachment(0, 120);
		data.right = new FormAttachment(97, 0);
		data.bottom = new FormAttachment(0, 30);
		quickT1.setLayoutData(data);

		// ---------------------------------------------
		Label l311 = new Label(quickComposite, SWT.NORMAL);
		l311.setImage(new Image(null,getClass().getResourceAsStream("check.png")));
		data = new FormData();
		data.top = new FormAttachment(0, 37);
		data.left = new FormAttachment(0, 5);
		data.right = new FormAttachment(0, 25);
		l311.setLayoutData(data);
		l311.setBackground(color);
		
		
		Label l52 = new Label(quickComposite, SWT.NORMAL);
		l52.setFont(font);
		l52.setBackground(color);
		l52.setText("checks");
		data = new FormData();
		data.top = new FormAttachment(0, 37);
		data.left = new FormAttachment(0, 35);
		data.right = new FormAttachment(0, 100);
		l52.setLayoutData(data);

		quickT2 = new Label(quickComposite, SWT.BORDER | SWT.CENTER);
		quickT2.setBackground(color);
		quickT2.setFont(font);
		data = new FormData();
		data.top = new FormAttachment(0, 30);
		data.left = new FormAttachment(0, 120);
		data.right = new FormAttachment(97, 0);
		data.bottom = new FormAttachment(0, 57);
		quickT2.setLayoutData(data);
		// ---------------------------------------------
		Label l315 = new Label(quickComposite, SWT.NORMAL);
		l315.setImage(new Image(null,getClass().getResourceAsStream("swap.png")));
		data = new FormData();
		data.top = new FormAttachment(0, 64);
		data.left = new FormAttachment(0, 5);
		data.right = new FormAttachment(0, 25);
		l315.setLayoutData(data);
		l315.setBackground(color);
		
		
		Label l53 = new Label(quickComposite, SWT.NORMAL);
		l53.setFont(font);
		l53.setBackground(color);
		l53.setText("Swaps");
		data = new FormData();
		data.top = new FormAttachment(0, 64);
		data.left = new FormAttachment(0, 35);
		data.right = new FormAttachment(0, 100);
		l53.setLayoutData(data);

		quickT3 = new Label(quickComposite, SWT.BORDER | SWT.CENTER);
		quickT3.setBackground(color);
		quickT3.setFont(font);
		data = new FormData();
		data.top = new FormAttachment(0, 57);
		data.left = new FormAttachment(0, 120);
		data.right = new FormAttachment(97, 0);
		data.bottom = new FormAttachment(0, 84);
		quickT3.setLayoutData(data);
		// ---------------------------------------------
		/** ***************************************************************** */
		PShelfItem heap = new PShelfItem(shelf, SWT.NONE);
		heap.setText("Heap Sort");
		Composite heapComposite = heap.getBody();
		heapComposite.setBackground(color);
		layout = new FormLayout();
		heapComposite.setLayout(layout);
		// ---------------------------------------------
		Label l320 = new Label(heapComposite, SWT.NORMAL);
		l320.setImage(new Image(null,getClass().getResourceAsStream("clock.png")));
		data = new FormData();
		data.top = new FormAttachment(0, 10);
		data.left = new FormAttachment(0, 5);
		data.right = new FormAttachment(0, 25);
		l320.setLayoutData(data);
		l320.setBackground(color);
		
		
		Label l61 = new Label(heapComposite, SWT.NORMAL);
		l61.setFont(font);
		l61.setBackground(color);
		l61.setText("Run Time (ns)");
		data = new FormData();
		data.top = new FormAttachment(0, 10);
		data.left = new FormAttachment(0, 35);
		data.right = new FormAttachment(0, 120);
		l61.setLayoutData(data);
		l61.setBackground(color);

		heapT1 = new Label(heapComposite, SWT.BORDER | SWT.CENTER | SWT.CENTER);
		heapT1.setBackground(color);
		heapT1.setFont(font);
		data = new FormData();
		data.top = new FormAttachment(0, 3);
		data.left = new FormAttachment(0, 120);
		data.right = new FormAttachment(97, 0);
		data.bottom = new FormAttachment(0, 30);
		heapT1.setLayoutData(data);

		// ---------------------------------------------
		Label l321 = new Label(heapComposite, SWT.NORMAL);
		l321.setImage(new Image(null,getClass().getResourceAsStream("check.png")));
		data = new FormData();
		data.top = new FormAttachment(0, 37);
		data.left = new FormAttachment(0, 5);
		data.right = new FormAttachment(0, 25);
		l321.setLayoutData(data);
		l321.setBackground(color);
		
		
		Label l62 = new Label(heapComposite, SWT.NORMAL);
		l62.setFont(font);
		l62.setBackground(color);
		l62.setText("checks");
		data = new FormData();
		data.top = new FormAttachment(0, 37);
		data.left = new FormAttachment(0, 35);
		data.right = new FormAttachment(0, 100);
		l62.setLayoutData(data);

		heapT2 = new Label(heapComposite, SWT.BORDER | SWT.CENTER);
		heapT2.setBackground(color);
		heapT2.setFont(font);
		data = new FormData();
		data.top = new FormAttachment(0, 30);
		data.left = new FormAttachment(0, 120);
		data.right = new FormAttachment(97, 0);
		data.bottom = new FormAttachment(0, 57);
		heapT2.setLayoutData(data);
		// ---------------------------------------------
		Label l322 = new Label(heapComposite, SWT.NORMAL);
		l322.setImage(new Image(null,getClass().getResourceAsStream("swap.png")));
		data = new FormData();
		data.top = new FormAttachment(0, 64);
		data.left = new FormAttachment(0, 5);
		data.right = new FormAttachment(0, 25);
		l322.setLayoutData(data);
		l322.setBackground(color);
		
		
		Label l63 = new Label(heapComposite, SWT.NORMAL);
		l63.setFont(font);
		l63.setBackground(color);
		l63.setText("Swaps");
		data = new FormData();
		data.top = new FormAttachment(0, 64);
		data.left = new FormAttachment(0, 35);
		data.right = new FormAttachment(0, 100);
		l63.setLayoutData(data);

		heapT3 = new Label(heapComposite, SWT.BORDER | SWT.CENTER);
		heapT3.setBackground(color);
		heapT3.setFont(font);
		data = new FormData();
		data.top = new FormAttachment(0, 57);
		data.left = new FormAttachment(0, 120);
		data.right = new FormAttachment(97, 0);
		data.bottom = new FormAttachment(0, 84);
		heapT3.setLayoutData(data);
		// ---------------------------------------------
		/** ***************************************************************** */
		gData = new GridData(GridData.FILL_BOTH);
		Composite upperSim = new Composite(composite ,SWT.NORMAL);
		upperSim.setLayoutData(gData);
		upperSim.setLayout(new GridLayout());
		upperSim.setBackground(color);
		
		final ScrolledComposite sc = new ScrolledComposite(upperSim , SWT.V_SCROLL | SWT.H_SCROLL);
		gData = new GridData(GridData.FILL_BOTH);
		sc.setLayoutData(gData);
		visualView = new Canvas(sc, SWT.BORDER | SWT.DOUBLE_BUFFERED);
		visualView.setBackground(color);
		visualView.addPaintListener(Painter.getInstance());
		Display.getCurrent().asyncExec(new Runnable(){
			public void run() {
				visualView.setSize(sc.getBounds().width, sc.getBounds().height);
				canvasWidth = visualView.getBounds().width;
				cnvasHeight = visualView.getBounds().height;
			}
		});
		sc.setContent(visualView);
		
		
		Runner.getInstance().createAnimationBar(upperSim);
		
		
		Group group = new Group (upperSim, SWT.SHADOW_ETCHED_OUT | SWT.SHADOW_IN |SWT.SHADOW_OUT);
		gData = new GridData(GridData.FILL_HORIZONTAL);
		group.setLayoutData(gData);
		group.setLayout(new FillLayout());
		group.setText("Current Simulation Technique");
		group.setBackground(color);
		simSortType = new Label(group , SWT.CENTER);
		simSortType.setFont(font);
		simSortType.setBackground(color);
		simSortType.setForeground(new Color(this.getDisplay() , new RGB(100,100,255)));
		
		Composite startComposite =new Composite(leftComposite,SWT.NORMAL);
		gData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING| GridData.FILL_HORIZONTAL);
		startComposite.setLayoutData(gData);
		startComposite.setBackground(color);
		startComposite.setLayout(new GridLayout(2,true));
		
		Label exitLabel= new Label(startComposite, SWT.DOUBLE_BUFFERED);
		exitLabel.setImage(new Image(null,getClass().getResourceAsStream("exitL.png")));
		exitLabel.setData("exit");
		
		Label startLabel= new Label(startComposite, SWT.DOUBLE_BUFFERED);
		startLabel.setImage(new Image(null,getClass().getResourceAsStream("startL.png")));
		startLabel.setData("start");
		gData =new GridData();
		gData.horizontalIndent=8;
		startLabel.setLayoutData(gData);
		
		StartListener startListener = new StartListener();
		exitLabel.addMouseListener(startListener);
		exitLabel.addMouseTrackListener(startListener);
		exitLabel.setBackground(color);
		
		sortControl =new SortControl();
		startLabel.addMouseListener(startListener);
		startLabel.addMouseListener(sortControl);
		startLabel.addMouseTrackListener(startListener);
		startLabel.setBackground(color);
	}

	public String getDirPath() {
		return path.getText();
	}

	public void removeFromlist(int index) {
		if(index != -1)
		sortList.remove(index);
		else
		remove.setEnabled(false);
	}

	public void addToList(String arrayName) {
		sortList.add(arrayName);
	}
	public int getAutoArraySize(){
		return Integer.parseInt(sizeText.getText());
	}
	public int getSelectArrayIndex() {
		return this.sortList.getSelectionIndex();
	}
	public boolean[] getSimulationArray(){
	 boolean [] visualTechs = new boolean [Sorters.values().length];
		visualTechs[0] = selectionSort.isChecked();
		visualTechs[1] = bubbleSort.isChecked();
		visualTechs[2] = shellSort.isChecked();
		visualTechs[3] = insertionSort.isChecked();
		visualTechs[4] = mergeSort.isChecked();
		visualTechs[5] = quickSort.isChecked();
		visualTechs[6] = heapSort.isChecked();
		return visualTechs;
	}
	@SuppressWarnings("unchecked")
	public void updatelist(ArrayList<Comparable[]> target){
	    sortList.removeAll();
	   int len=target.size();
	   for (int i = 1; i <= len; i++) {
	       sortList.add("Array "+i);
	   }
	}
	
	public void setStatistics(Statistics[] statistics){
	    selectionT1.setText(""+statistics[0].getRunTime());
	    selectionT2.setText(""+statistics[0].getCheks());
	    selectionT3.setText(""+statistics[0].getSwaps());
	    
	    bubbleT1.setText(""+statistics[1].getRunTime());
	    bubbleT2.setText(""+statistics[1].getCheks());
	    bubbleT3.setText(""+statistics[1].getSwaps());
	    
	    shellT1.setText(""+statistics[2].getRunTime());
	    shellT2.setText(""+statistics[2].getCheks());
	    shellT3.setText(""+statistics[2].getSwaps());
	    
	    insertionT1.setText(""+statistics[3].getRunTime());
	    insertionT2.setText(""+statistics[3].getCheks());
	    insertionT3.setText(""+statistics[3].getSwaps());
	    
	    mergeT1.setText(""+statistics[4].getRunTime());
	    mergeT2.setText(""+statistics[4].getCheks());
	    mergeT3.setText(""+statistics[4].getSwaps());
	    
	    quickT1.setText(""+statistics[5].getRunTime());
	    quickT2.setText(""+statistics[5].getCheks());
	    quickT3.setText(""+statistics[5].getSwaps());
	    
	    heapT1.setText(""+statistics[6].getRunTime());
	    heapT2.setText(""+statistics[6].getCheks());
	    heapT3.setText(""+statistics[6].getSwaps());
	}
	
	public Canvas getCanvas(){
		return visualView;	
	}
	/**
	 * @return  the canvasWidth
	 * @uml.property  name="canvasWidth"
	 */
	public int getCanvasWidth(){
		return canvasWidth;
	}
	public int getCanvasHeight(){
		return cnvasHeight;
	}
	/**
	 * @return  the display
	 * @uml.property  name="display"
	 */
	public Display getDisplay(){
		return display;
	}
	public void setSimulationName(final String sortType){
		if(!simSortType.isDisposed()){
		simSortType.getDisplay().asyncExec(new Runnable(){
			public void run() {
				if(!simSortType.isDisposed()){
				simSortType.setText(sortType);
//				simSortType.redraw();
				}
			}
		});
		}
	}

	/**
	 * @return  the visualView
	 * @uml.property  name="visualView"
	 */
	public Canvas getVisualView() {
		return visualView;
	}
	/**
	 * @return  the shell
	 * @uml.property  name="shell"
	 */
	public Shell getShell(){
		return shell;
	}
}
